import pygame

pygame.init()

WIN_WIDTH = 400
WIN_HEIGHT = 600

window = pygame.display.set_mode((WIN_WIDTH, WIN_HEIGHT))

pygame.display.set_caption('简单动画')

window.fill((255, 255, 255))

pygame.display.flip()


def dran_circle(y: int, r: int):
    """
        画球函数
    :return:
    """
    pygame.draw.circle(window, (255, 234, 123), (200, y), r)
    pygame.display.update()


y: int = 100
r: int = 50

num = 1
while True:
    num += 1
    if num % 10 == 0:
        pygame.draw.circle(window, (255, 255, 255), (200, y), r)
        if y > 600:
            y -= 1
            dran_circle(y, r)
        elif y < 0:
            y += 1
            dran_circle(y, r)
        else:
            y += 1
            dran_circle(y, r)

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            exit()
